package edu.yuhf.domain;

import edu.yuhf.databasedemo.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

public class SubjectMapper implements ResultSetHandler<Subject> {
    @Override
    public Subject handler(ResultSet resultSet) {
        Subject subject = new Subject();
        try {
            subject.setId(resultSet.getInt("id"));
            subject.setSubjectName(resultSet.getString("subject_name"));
            subject.setCredit(resultSet.getInt("credit"));
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return subject;
    }
}
